package org.example.sbringboot1_12.controller;

import jakarta.servlet.http.HttpServletResponse;
import org.example.sbringboot1_12.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/response")
//@RestController
@Controller
//@ResponseBody
public class ResponseController {
   @RequestMapping("/returnHtmlPage")
    public String returnHtmlPage(){
        return "/hello.html";
    }
    @ResponseBody
    @RequestMapping("/returnData")
    public String returnData(){
        return "/hello.html";
    }
    @ResponseBody
    @RequestMapping("/returnHtml")
    public String returnHtml(){
        return "<h1>returnHtml</h1>";
    }
    @ResponseBody
    @RequestMapping("/returnJson")
    public User returnJson(){
       User user=new User();
       user.setName("zhangsan");
       user.setAge(18);
       return user;
    }
    @ResponseBody
    @RequestMapping("/setStatus")
    public User setStatus(HttpServletResponse response){
        User user=new User();
        user.setName("zhangsan");
        user.setAge(18);
        response.setStatus(500);
        return user;
    }
}
